﻿using System;
using System.Diagnostics;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Tests.PC1
{
    [TestClass]
    public class OpcodeGenerator
    {
        [TestMethod]
        public void Gen()
        {
            const int rCount = 4;

            var b = new StringBuilder();

            var ops = new[]
            {
                Tuple.Create("ADD", 1),
                Tuple.Create("SUB", 2)
            };
            foreach (var op in ops)
            {
                for (var d = 0; d < rCount; d++)
                {
                    for (var n = 0; n < rCount; n++)
                    {
                        for (var m = 0; m < rCount; m++)
                        {
                            var opname = string.Format(
                                "{0}_R{1}_R{2}_R{3}",
                                op.Item1,
                                d,
                                n,
                                m);

                            var opcode =
                                100000 +
                                1000*op.Item2 +
                                100*d +
                                10*n +
                                m;

                            b.Append(opname)
                                .Append(" = ")
                                .Append(opcode)
                                .AppendLine(",");
                        }
                    }
                }
            }

            Debug.WriteLine(b.ToString());
        }
    }
}